Multi-rate hierarchical state diagrams

ABSTRACT

Systems and methods are provided for a scheme and mechanism for performing static analysis of a sample time aware state diagram model to compute and propagate multiple samples rates associated with the state diagram model. A graphical intermediate representation of the state diagram model, such as a directed graph or control flow graph, is used to determine how the multiple sample rates are propagated via elements of the state diagram model. The graph provides a static representation of the control of flow, including alternative and/or conditional flow paths, of the state diagram model. The present invention determines the propagation of sample rates via analysis and traversal of the intermediate representation. By using the techniques of the present invention, a state diagram model may provide multiple sample rate outputs, such as by function calls and output signals to a graphical model, such as a model representing a dynamic system.

TECHNICAL FIELD

The present invention generally relates to propagating multiple samplesrates in a state diagram model.

BACKGROUND INFORMATION

State diagram models, such as state diagrams produced with Stateflow®from The MathWorks, Inc. of Natick, Mass., are event-based and thereforereactive without any notion of time. In contrast, graphical modeling andsimulation tools, such as Simulink® also from The MathWorks, Inc.,provide dynamic system modeling and simulation to represent andpropagate multiple sample times or rates for different components in asystem. Designing and simulating with multiple samples rates fordifferent components of the system provides for testing to ensure theintegrity of data access between the different components In some cases,state diagrams may be used to schedule the execution of differentcomponents in a graphical model or simulation of the system. Forexample, in state diagrams of Stateflow®, temporal operators andfunction call outputs may be used to trigger execution of differentcomponents in a Simulink® graphical model.

While the schedulers implemented using a state diagram model allow for avariety of scheduling designs, a state diagram model does not providefor propagating multiple samples rates to drive the scheduling,triggering or execution of the different components of a simulatedsystem. The reactive event-based nature along with the Turing-completenature of a state diagram model, such as a Stateflow® diagram, makes itchallenging to propagate the sample times to the component subsystems.Additionally, state diagram based schedulers do not execute differentcomponents of the system based on different sample rates. As such, statediagram models integrated or interfacing with a graphical model of asystem for simulation limits the design, simulation and testing ofvarious different components via multiple sample rates.

SUMMARY OF THE INVENTION

The present invention provides systems and methods for processing and/orpropagating multiple sample rates via a state diagram model, such asStateflow®. The state diagram model may receive or process multipleinput signals having different sample rates, and the state diagram modelmay also use temporal operators related to input signals that alter thepropagation of sampling rates. Additionally, the state diagram model maybe sample time aware by configuring or specifying sample rates fordifferent elements of the state diagram model, such as assigning asample rate to one or more states of the state diagram model.

The techniques of the present invention provide a scheme and mechanismsfor static analysis of a state diagram model to compute and propagatemultiple samples rates associated with the state diagram model. In oneembodiment of the present invention, a graphical intermediaterepresentation of the state diagram model, such as a directed graph orcontrol flow graph, is used to determine how the multiple sample ratesare propagated via elements of the state diagram model. The graphprovides a static representation of the control of flow, includingalternative and/or conditional flow paths, of the state diagram model.The present invention determines the propagation of sample rates viaanalysis and traversal of the intermediate representation. By using thetechniques of the present invention, a state diagram model may providemultiple sample rate outputs, such as by function calls and outputsignals to a graphical model, such as Simulink®. For example, aStateflow® diagram may be used with a Simulink® graphical model toprovide for scheduling or execution of different components of thegraphical model for simulation. Using the techniques of the presentinvention, the Stateflow® diagram may provide different sample rates fortriggering or executing the graphical model components via outputfunctions or output signals.

In one aspect, the present invention is related to a method forprocessing a state diagram model to provide an executable form of thestate diagram model propagating a plurality of rates associated with thestate diagram model. The rates may comprise a sample rate, executionrate, or a data rate. The method includes providing a state diagrammodel having one or more elements and a plurality of rates associatedwith the one or more elements. The plurality of rates includes a firstrate and a second rate, and the second rate may be different than thefirst rate. The method of the present invention processes the statediagram model to provide an executable form of the state diagram modelrepresenting a propagation of the plurality of rates via the one or moreelements. The executable form represents a first portion of the statediagram model using the first rate and a second portion of the statediagram model using the second rate.

In another aspect, the method of the present invention provides at leastone of the plurality of rates via a portion of a signal provided as aninput to the one or more elements of the state diagram model. The methodmay also provide an executable instruction associated with the statediagram model to provide at least one of the plurality of rates bychanging a frequency of one of a propagation of a signal or a calling ofan output function. Additionally, the method may assign a rate of theplurality of sample rates to one or more states of the state diagrammodel.

In one aspect of the present invention, the method processes the statediagram model by generating a graphical representation of a flow ofexecution of the state diagram model. The graphical representation mayinclude a directed graph or a control flow graph. The method may processthe graphical representation to determine from the plurality of rates arate to apply for one of an output signal or output function of thestate diagram model.

In an additional aspect of the present invention, the state diagrammodel is provided via a graphical model that incorporates or referencesthe state diagram model. The first portion of the state diagram modelusing the first rate or the second portion of the state diagram modelusing the second rate may be associated with or otherwise provide anoutput to a graphical model, such as a block diagram model. In oneaspect, the method of the present invention may process the statediagram model into the executable form by generating code representingthe state diagram model and compiling the code into an executable file.

In another aspect, the present invention relates to a device readablemedium having device readable instructions to execute the steps of themethod, as described above, related to processing a state diagram modelto provide an executable form of the state diagram model propagating aplurality of rates associated with the state diagram model.

In a further aspect, the present invention relates to transmitting via atransmission medium computer data signals representing device readableinstructions to execute the steps of the method, as described above,related to processing a state diagram model to provide an executableform of the state diagram model propagating a plurality of ratesassociated with the state diagram model.

In one aspect, the present invention is related to a method forexecuting a state diagram model to propagate multiple rates, such as asample rate, an execution rate, or a data rate. The method includesproviding an executable form of a state diagram model. The executableform represents a propagation of multiple rates via one or more elementsof the state diagram model. The method includes executing the executableform to use a first rate of the multiple rates for a first portion ofthe executable form and a second rate of the multiple rates for a secondportion of the executable form.

In another aspect of the present invention, the method includespropagating a first input signal having the first rate and propagating asecond input signal having the second rate. The first rate or the secondrate may be used for an output signal or an output function of the statediagram model. In an additional aspect, the one or more elements of thestate diagram model represent a first state assigned the first rate or asecond state assigned the second rate.

In other aspects of the present invention, executing the executable formof the state diagram model provides a simulation of the state diagrammodel.

In an additional aspect of the present invention, the executable form ofthe state diagram model is provided via an executable form of agraphical model that may incorporate or reference the state diagrammodel. An output to a graphical model, such as a block diagram model,may be provided by the first portion of the state diagram model usingthe first rate or the second portion of the state diagram model usingthe second rate. In other aspects, the method of the present inventionmay provide the executable form of the state diagram model by generatingcode representing the state diagram model and compiling the code into anexecutable file.

In one aspect, the present invention relates to a device readable mediumhaving device readable instructions to execute the steps of the method,as described above, related to executing a state diagram model topropagate multiple rates.

In a further aspect, the present invention relates to transmitting via atransmission medium computer data signals representing device readableinstructions to execute the steps of the method, as described above,related to executing a state diagram model to propagate multiple rates.

In one aspect, the present invention is related to a system forprocessing a state diagram model to propagate a plurality of ratesassociated with one or more elements of the state diagram model. Therates may include a sample rate, execution rate, or data rate. Thesystem includes a state diagram model having a plurality of ratesassociated with one or more elements of the state diagram model. Theplurality of rates has a first rate and a second rate. The second ratemay be different than the first rate. The system also includes aprocessing tool to provide an executable form of the state diagram modelrepresenting a propagation of the plurality of rates via the one or moreelements of the state diagram model. The executable form represents afirst portion of the state diagram model using the first rate and asecond portion of the state diagram model using the second rate.

In an additional aspect of the system of the present invention, thestate diagram model includes a signal having a rate provided as input tothe one or more elements. The state diagram model may also include anexecutable instruction providing one of the plurality of rates bychanging a frequency of a propagation of a signal via the one or moreelements. Additionally, the state diagram model may include one or morestates assigned one or more of the plurality of rates. The one or moreelements may represent a first state assigned the first rate or a secondstate assigned the second rate.

In a further aspect, the processing tool of the present inventiongenerates a graphical representation of a flow of execution of the statediagram model. The graphical representation may include a directed graphor a control flow graph. The processing tool may use the graphicalrepresentation to determine from the plurality of samples rates a rateto apply for one of an output signal or an output function of the statediagram model. Also, the processing tool may propagate a first inputsignal having the first rate and propagate a second input signal havingthe second rate.

In another aspect of the present invention, the processing tool providesan executable form to use the first rate for a first portion of theexecutable form and the second rate for a second portion of theexecutable form. In some aspects, the processing tool applies the firstrate or the second rate to an output signal or an output function of thestate diagram model. The executable form may be executed to provide asimulation of the state diagram model.

In aspect of the system of the present invention, an executable form ofa graphical model may include the executable form of the state diagrammodel. An output may be provided to the graphical model by executing thefirst portion of the state diagram model using the first rate or thesecond portion of the state diagram model using the second rate. Inanother aspect, the processing tool of the present invention may includea code generator for generating code representing the state diagrammodel and compiling the code into an executable file.

In further aspects, the system of the present invention may bedistributed and/or executed on one or more computing devices. In oneaspect, the state diagram model is provided via a first computing deviceand the processing tool executes on a second computing device. Inanother aspect, a first portion or a second portion of the executableform executes on either a first computing device or a second computingdevice.

The details of various embodiments of the invention are set forth in theaccompanying drawings and the description below.

BRIEF DESCRIPTION OF THE DRAWINGS

The foregoing and other objects, aspects, features, and advantages ofthe invention will become more apparent and may be better understood byreferring to the following description taken in conjunction with theaccompanying drawings, in which:

FIG. 1 is a block diagram of an illustrative computing device forpracticing an embodiment of the present invention;

FIG. 2A is a block diagram of an illustrative state diagram modelingenvironment for practicing an embodiment of the present invention on thecomputing device of FIG. 1;

FIG. 2B is a block diagram of another illustrative state diagrammodeling environment for practicing an embodiment of the presentinvention in a network environment;

FIG. 2C is a block diagram of another illustrative state diagrammodeling environment for practicing an embodiment of the presentinvention in a distributed environment;

FIG. 3A is a is a diagrammatic view of an illustrative state diagrammodel having multiple input signals for practicing an embodiment of thepresent invention

FIG. 3B is a diagrammatic view of an illustrative state diagram modelusing temporal operators for practicing another embodiment of thepresent invention;

FIG. 3C is a diagrammatic view of an illustrative state diagram modelassigning sample rates to states for practicing another embodiment ofthe present invention;

FIG. 4A is a diagrammatic view of another illustrative state diagrammodel for practicing an embodiment of the present invention;

FIG. 4B is a flow diagram depicting an illustrative method forpracticing an embodiment of the present invention to process the statediagram model of FIG. 4A;

FIG. 4C is a diagrammatic view of an illustrative intermediaterepresentation of the state diagram model of FIG. 4A for practicing thetechniques of the present invention;

FIG. 5A is a flow diagram depicting an illustrative method forpracticing an embodiment of the present invention to generate code foran illustrative state diagram model; and

FIG. 5B is a block diagram of an illustrative code generation system forpracticing an embodiment of the present invention.

DETAILED DESCRIPTION

Certain embodiments of the present invention are described below. It is,however, expressly noted that the present invention is not limited tothese embodiments, but rather the intention is that additions andmodifications to what is expressly described herein also are includedwithin the scope of the invention. Moreover, it is to be understood thatthe features of the various embodiments described herein are notmutually exclusive and can exist in various combinations andpermutations, even if such combinations or permutations are notexpressly made herein, without departing from the spirit and scope ofthe invention.

The illustrative embodiment of the present invention provides systemsand methods for processing and/or propagating multiple sample ratesassociated with a state diagram model. In one embodiment, the statediagram model may receive or process multiple input signals havingdifferent sample rates. For example, the state diagram model may receiveone or more input signals having different sampling rates from agraphical or simulation model. In other embodiments, the state diagrammodel may include one or more temporal operators that provide eventbased occurrence and conditional based triggering of functionality. Assuch, temporal operators may provide multiple sample rates viaprocessing, propagation, or processing of operations of the statediagram model. For example, temporal operators may provide for differentfrequencies of propagation of input signals to the output signal or forcalling an output function to trigger a component of a simulationsystem. Additionally, the state diagram model may be sample time awareby configuring or specifying sample rates for different elements of thestate diagram model, such as states represented by the state diagrammodel. For example a first state of the state diagram model may beconfigured to execute at a first rate while a second state may beconfigured to execute at a second sample rate.

The techniques of the present invention provide a scheme and mechanismsfor static analysis of a state diagram model to compute and propagatemultiple samples rates associated with the state diagram model. Theillustrative embodiment may be performed during compilation orprocessing of the state diagram model into an executable form. Theillustrative techniques of the present invention provides anintermediate representation of the state diagram model, such as adirected graph or control flow graph, to determine how the multiplesample rates are propagated via elements of the state diagram model. Thedirected or control flow graph provides a static representation of thecontrol of flow, including alternative and/or conditional flow paths, ofthe state diagram model. Via the traversal and analysis of samples ratesthrough the static intermediate representation, the present inventiondetermines the propagation of sampling rates to provide for executionand output of an executable form of the state diagram model.

By using the techniques of the illustrative embodiment of the presentinvention, a state diagram model may provide multiple sample rateoutputs, such as by function calls and output signals to a graphicalmodel, such as Simulink® For example, a Stateflow® diagram may be usedwith a Simulink® graphical model to provide for scheduling or executionof different components of the graphical model for simulation. TheStateflow® diagram may provide different sample rates for triggering orexecuting the graphical model components via output functions or outputsignals. Furthermore, the execution of the state diagram model may besample time aware so that elements such as states execute and processoperations according to their assigned samples rates. As such, the statediagram model can be reactive and event-based and also execute in asample time aware manner.

The illustrative embodiment will be described solely for illustrativepurposes relative to a state diagram and graphical modeling environmentprovided by the software products from The MathWorks, Inc. of Natick,Mass. Although the illustrative embodiment will be described relative toa Stateflow® and/or Simulink®-based application, including the use ofMATLAB®, one of ordinary skill in the art will appreciate that thepresent invention may be applied to other state diagram model and/orgraphical modeling environments, such as any environment using softwareproducts of LabVIEW® or MATRIXx from National Instruments, Inc.,MSC.Adams® from MSC.Software Corporation of Santa Ana, Calif., Virtuosofrom Cadence of San Jose, Calif., Dymola from Dynasim AB of Lund,Sweden, Rational Rose from IBM of White Plains, N.Y., Mathematica® fromWolfram Research, Inc. of Champaign, Ill., Mathcad from MathsoftEngineering & Education Inc., or Maple™ from Maplesoft, a division ofWaterloo Maple Inc.

FIG. 1 depicts an environment suitable for practicing an illustrativeembodiment of the present invention. The environment includes acomputing device 102 having memory 106, on which software according toone embodiment of the present invention may be stored, a processor (CPU)104 for executing software stored in the memory 106, and other programsfor controlling system hardware. The memory 106 may comprise a computersystem memory or random access memory such as DRAM, SRAM, EDO RAM, etc.The memory 106 may comprise other types of memory as well, orcombinations thereof. A human user may interact with the computingdevice 102 through a visual display device 114 such as a computermonitor, which may be used to display a graphical user interface (GUI).

The computing device 102 may include other I/O devices such a keyboard110 and a pointing device 112, for example a mouse, for receiving inputfrom a user. Optionally, the keyboard 110 and the pointing device 112may be connected to the visual display device 114. Additionally, thecomputing device 102 may include any type of input device for receivinguser input, such as a joystick. In other embodiments, the computingdevice 102 may include any type of haptic or tactile feedback device,such as a vibration generating mouse, or a force feedback device such asa force feedback joystick. Also, the computing device 102 may includeany type of sound producing I/O device such as any suitable sound card.The computing device 102 may include other suitable conventional I/Operipherals.

For installing software programs, the computing device 102 may supportany suitable device readable medium 116, such as a CD-ROM, DVD-ROMfloppy disks, tape device, USB device, hard-drive, or any other suitabledevice. The computing device 102 may further comprise a storage device108, such as a hard-drive or CD-ROM, for storing an operating system andother related software. The present invention of a state diagrammodeling environment 120 may comprise software that is installed via adevice readable medium 116 and stored in the storage device 108.Additionally, the operating system and state diagram modelingenvironment 120 can be run from a bootable CD, such as, for example,KNOPPIX®, a bootable CD for GNU/Linux.

Additionally, the computing device 102 may include a network interface118 to interface to a Local Area Network (LAN), Wide Area Network (WAN)or the Internet through a variety of connections including, but notlimited to, standard telephone lines, LAN or WAN links (e.g., 802.11,T1, T3, 56 kb, X.25), broadband connections (e.g., ISDN, Frame Relay,ATM), cluster interconnection (Myrinet), peripheral componentinterconnections (PCI, PCI-X), wireless connections, or some combinationof any or all of the above. The network interface 118 may comprise abuilt-in network adapter, network interface card, PCMCIA network card,card bus network adapter, wireless network adapter, USB network adapter,modem or any other device suitable for interfacing the computing device118 to any type of network capable of communication and performing theoperations described herein. Moreover, the computing device 102 may beany computer system such as a workstation, desktop computer, server,laptop, handheld computer or other form of computing ortelecommunications device that is capable of communication and that hassufficient processor power and memory capacity to perform the operationsdescribed herein.

In one aspect, the present invention is related to a state diagrammodeling environment 120 as illustrated in FIG. 2A. In brief overview,the illustrative state diagram modeling environment 120 includes a statediagram modeling tool 220, a graphical modeling tool 230, and a codebuilding tool 290. The state diagram modeling tool 230 provides anenvironment for the design, development, testing, simulation, andexecution of a state diagram model 225. The graphical modeling tool 230provides an environment for the design, development, testing,simulation, and execution of a graphical model 235, such as a blockdiagram model. The graphical modeling tool 230 may also provide forincorporating or referencing a state diagram model 225 via the graphicalmodel 235. The code building tool 290 may include a code generator 295to provide for the code generation and building of executable forms ofthe state diagram model 225 and/or graphical model 235. The statediagram modeling tool 220 may be in communication with the graphicalmodeling tool 230 via any suitable type and form of interface. The codebuilding tool 290 may be in communication with or otherwise have anysuitable type and form of interface to the state diagram modeling tool220 and/or the graphical modeling tool 230.

The illustrative state diagram modeling tool 220 of the presentinvention comprises a design and development environment for creatingany type and/or form of state diagram model 225, which may also bereferred to as a state machine diagram model, a state diagram, a statechart or chart. In an exemplary embodiment and by way of example, thestate diagram modeling tool 220 may comprise Stateflow® by TheMathWorks, Inc. of Natick, Mass. In the exemplary embodiment ofStateflow®, the state diagram model 225 may be referred to as aStateflow chart. Stateflow® integrates with graphical modeling tools,such as Simulink® by The MathWorks, Inc. of Natick, Mass., to model,simulate, and analyze systems. In one embodiment, Stateflow® providesfor the design and development of deterministic, supervisory controlsystems in a graphical environment. The state diagram modeling tool 220provides for state machine representation, flow diagram notations, andstate-transition diagrams all in the same diagram model 225.

A state diagram model 225 may comprise a graphical representation of astate machine, such as either a finite state machine or anon-deterministic state machine, where states and transitions form thebuilding blocks of a system. As known to those ordinarily skilled in theart, a state machine is a representation of an event driven system wherethe system makes a transition from one state to another state providedany conditions associated with the transition are met. A state may be amode of behavior that can be either active or inactive based on inputs,outputs, transitions, and conditions. A transition links one state toanother state and may have a condition, such as any logic, computation,algorithm, or executable instruction, used to determine if and when atransition between states may occur. In some embodiments of the statediagram model 225, any of the states may be specified to have either aparallel (AND) or an exclusive (OR) decomposition with respect to anysub-states associated with a state, such as in the illustrativeembodiment of Stateflow® as the state diagram modeling tool 220. A statewith a parallel decomposition may comprise one or more sub-states thatare active at the same time when the state is active and/or anothersub-state is active. For example, one or more selected sub-states may beactive in parallel or at the same time when the state is active. A statewith an exclusive decomposition may comprise only one sub-state that isactive when the state is active. One ordinarily skilled in the art willrecognize and appreciate how states and sub-states may be specified orconfigured to operate in a parallel or exclusive manner.

In another embodiment of the present invention, a truth table, graphicalor otherwise, may be used to represent the relationships between inputs,outputs, states, transitions, and conditions of a finite state machine.Although generally discussed herein as a graphical state diagram model,one ordinarily skilled in the art will recognize and appreciate that anytype of graphical state model may be used and that any type of statemachine, such as a finite, non-deterministic, or a virtual state machinemay be used in practicing the present invention. Additionally, the statediagram modeling tool 220 and/or state diagram model 225 may use anytype and/or form of notation for state machine representation, such asany notation known by those ordinarily skilled in the art, or anynotation suitable for practicing the operations of the presentinvention.

The state diagram modeling tool 220 may provide elements such as states,junctions, and functions, such as graphical functions of Simulink®and/or Stateflow®, that may be placed and arranged graphically in awindow, design area or otherwise collectively in a state diagram model225. States and junctions may be connected together in the state diagrammodel 225 to form flows and transitions for an implementation of a statemachine. The state diagram modeling tool 220 and/or state diagram model225 may provide for parallelism in that two or more orthogonal statesmay be active at the same time. Additionally, the state diagram modelingtool 220 and/or state diagram model 225 may provide a mechanism forspecifying transitions and/or conditions based on historical informationrelated to execution of the state diagram model 225. Additionally, thestate diagram modeling tool 220 and/or state diagram model 225 may useany type and/or form of graphical element to visually representelements, such as for state machine representation, in a state machinediagram model 225

In some embodiments, the state diagram modeling tool 220 and/or statediagram model 225 may provide for the use of temporal operators. In theexemplary embodiment of Stateflow®, temporal operators provide logic andBoolean operators that operate on recurrence counts of Stateflow®events, such as those provided by input signals to the state diagrammodel 225 or otherwise created by the operations or logic of the statediagram model 225. For example, Stateflow® provides for the temporaloperators of after, before, at and every to include in a state diagrammodel 225. By way of illustration, the after operator has a syntax of“after (n, E)”, where E is the base event for the operator and n is aninteger value or expression that evaluates to an integer value. Theafter operator is true if the base event E has occurred n times sinceactivation of its associated state. Otherwise, it is false. If the chart225 has no input events, after (n, wakeup) or after (n, tick)) operatorevaluates to true after the chart 225 has woken up n times. The tick andwakeup keywords specify an implicit event and are used to generate alocal event when the chart 225 of the action being evaluated awakens.The following example illustrates use of the after operator in atransition expression: CLK[after(10, CLK) && temp==COLD]. This exampleprovides a transition out of an associated state only if there has been10 occurrences of the CLK event since the state was activated and thetemp data item has the value COLD.

In a further example of a temporal operator, the before operator has thefollowing syntax “before (n, E)”, where the operator is true if the baseevent E has occurred less than n times since activation of itsassociated state. In a chart 225 with no input events, for example, thebefore (n, wakeup) or before (n, tick) operator evaluates to true beforethe chart has woken up n times. In another example of a temporaloperations, the syntax for the every operator is “every (n, E).” Theevery operator is true at every nth occurrence of the base event E sinceactivation of its associated state. The every (n, wakeup) or every (n,tick)) evaluates to true in a chart 225 with no input events andwhenever the chart wakes up an integer multiple n times. In anotherexample, the at operator has a syntax of at (n, E) and is true only atthe n^(th) occurrence of the base event E since activation of itsassociated state. In a chart 225 with no input events, at (n, wakeup) orat (n, tick)) evaluates to true when the chart wakes up for the n^(th)time. Although temporal operators are generally described in anexemplary embodiment of Stateflow®, one ordinarily skilled in the artwill recognize and appreciate that temporal operators may be expressedin many different forms, including having other temporal operations andmay be provided in other languages and environments.

Furthermore, the state diagram modeling tool 220 may provide fororganizing, incorporating, and referring sub-charts, hierarchically orotherwise, into a state diagram model 225. For example, a first statediagram model 225′ representing a portion of an overall state machinedesign may be incorporated into or referenced by a top level statediagram model 225. The state diagram model 225 may be organizedhierarchically into any number and/or levels of state diagram models torepresent a finite state machine.

Although the state diagram modeling tool 220 is generally discussed inview of Stateflow®, one ordinarily skilled in the art will recognize andappreciate the various forms and types of state diagram modeling toolsthat may be used in practicing the operations of the present inventionas described herein. In some embodiments, the state diagram modelingtool 220 may comprise any type and/or form of Petri net modeling andsimulation tool. For example, the state diagram modeling tool 220 maycomprise any of the Petri modeling and simulation libraries or toolsmanufactured by Dynasim AB of Lund, Sweden. The state diagram model 225may comprise a visual formalism or graphical model 235 representing aPetri net model or system. As one ordinarily skilled in the art willrecognize and appreciate, a Petri net is a graphical and mathematicalmodeling tool that provides a mathematical expression of discretedistributed systems and may be expressed in terms of places,transitions, and arcs that connect them. Petri nets may be used todescribe and model systems that may be characterized as beingconcurrent, asynchronous, distributed, parallel, nondeterministic,and/or stochastic. Additionally, tokens or tickets are used in Petrinets to simulate the dynamic and concurrent activities of systems.Accordingly, the state diagram model 225 may comprise any type and/orform of constructs and elements representing a Petri net model, such asa place, a transition, an arc, a token or a ticket as one ordinarilyskilled in the art would recognize and appreciate.

In some embodiments, the state diagram modeling tool 220 may compriseany type and/or form of event modeling and simulation tool, such as anydiscrete, continuous or hybrid event simulation system. For example, thestate diagram modeling tool 220 may comprise any of the event modelingand simulation tools manufactured by Imagine That, Inc. of San Jose,Calif., or Simul8 Corporation of Boston, Mass. Accordingly, the statediagram model 225 may comprise a visual formalism or graphical modelrepresenting a continuous, discrete, or event modeling system. As oneordinarily skilled in the art will recognize and appreciate, an eventmodeling tool 220 and diagram model 225 may represent system behaviorthat can be expressed in terms of what a system does in correspondenceto an event or a certain number of event types, and may use modelconstructs or elements representing queues and/or servers. For example,in a state diagram model 225, a queue element may represent a queue ofevents, and a server element may represent an event server thatprocesses events from the queue.

Additionally, in some embodiments, the state diagram modeling tool 220may be able to execute the state diagram model 225. For example, in theexemplary embodiment of Stateflow®, the state diagram modeling tool 220has a graphical execution and debugging environment that provides a usercontrol of the simulation execution of the state diagram model 225, andaccess to debug related tasks, such as setting breakpoints.Additionally, the state diagram modeling tool 220 may displayinformation about the state machine, such as active and inactive statesduring execution or other information as requested or desired by theuser.

In some embodiments, the state diagram modeling tool 220 is included in,integrated with, or is otherwise associated with a graphical modelingtool 230. The graphical modeling tool 230 of the present inventionprovides a graphical modeling environment for creating, designing,simulating, testing, and verifying a graphical model 235, such as ablock diagram model. In an exemplary embodiment, the graphical modelingtool 230 includes the graphical modeling environment of Simulink® fromthe MathWorks, Inc. of Natick, Mass. In the graphical modeling tool 230,configurable and customizable functional blocks are used to create blockdiagram models that may represent a design, or algorithm, for a controlsystem, a signal processing system, a communication system, any othertime-varying or dynamic system or any computational hardware device. Inother embodiments, the state diagram modeling tool 220 is separate fromthe graphical modeling tool 230 but is otherwise interfaced or incommunication with the graphical modeling tool 230.

The graphical model 235 of the present invention can comprise any typeand/or form of graphical model 235. The graphical modeling tool 230 mayprovide any type of tools, libraries, and configuration mechanisms tographically create and/or edit a graphical model 235. In an exemplaryembodiment, the graphical model 235 may comprise a block diagram modelprovided by the Simulink® environment of The MathWorks, Inc. Forexample, the block diagram model 235 may comprise a series of differenttype of blocks arranged in a desired manner and connected via connectionlines to represent signal values traversing the blocks. The graphicalmodel 235 may comprise any type of element to form a graphical model,such as connectors, blocks, or any other graphical form andrepresentation of functionality supported by the graphical modeling tool230. One ordinarily skilled in the art will recognize and appreciate thevarious forms of graphical models, and the elements and content thereof.

In one embodiment, the graphical model 235 incorporates, references, orotherwise uses the state diagram model 225 provided by the state diagrammodeling tool 220. In an exemplary embodiment, Stateflow® is integratedand used with Simulink® to provide an environment combing state diagrammodeling of Stateflow® with the graphical modeling of Simulink®. Thegraphical model 225 can include any elements provided for creating agraphical model 225 by the graphical modeling tool 230, such as anyelements of a block diagram model known by those ordinarily skilled inthe art, and can include a state diagram model 225, or any portionthereof, that may be provided by the state diagram modeling tool 220.For example, the graphical model 235 may comprise a block diagram modelwith blocks connected as inputs and/or outputs of the state machinediagram 225.

In one embodiment, the graphical modeling tool 230 may be able tosimulate or execute the graphical model 235. For example, in theexemplary embodiment of Simulink®, the graphical modeling tool 230 hasan environment that provides for the simulation and debugging of thegraphical model 225. Additionally, in other embodiments, the graphicalmodeling tool 230 may generate code of executable instructionsrepresenting the graphical model 235 to compile and build for executingon a target hardware platform and/or operating system. As such, thegraphical model 225 and/or state diagram model 220 can be processed intoan executable form to simulate, run, or otherwise execute the design,functionality, and/or operations represented by the graphical model 225and/or state diagram model 220. An executable form of the graphicalmodel 225 and/or state diagram model 220 may be any type and/or form ofrepresentation of the graphical model 225 and/or state diagram model 220that can be simulated, run or executed, and may comprise any graphicaland/or textual forms, interpreted languages or scripts, or programminglanguages, or any combination thereof. In some embodiments, theexecutable form of the graphical model 225 and/or state diagram model220 may comprise any type of interpreted language, such as MATLAB®. Inother embodiments, the executable form of the graphical model 225 and/orstate diagram model 220 may comprise any type of executableinstructions, such as scripts, libraries, or compiled executables.

The state diagram modeling environment 120 may include a code buildingtool 290 for generating code and building an executable form of thegraphical model 235 and/or state diagram model 220. The code buildingtool 290 comprises a code generator 295, such as the automatic codegenerator of Real-Time Workshop® from The MathWorks, Inc. of Natick,Mass. The code generator 295 generates source code from a graphicalmodel 235 and/or state diagram model 220 to translate the functionalityof the graphical model 235 and/or state diagram model 220 into a programthat may be designed to run on any processor, operating system, orotherwise customized to run on a specific target hardware platform.

The state diagram modeling tool 220, graphical modeling tool 230, andcode building tool 290 and any portion thereof, can comprise anapplication, module, service, computer program, software component,library, or any other type and/or form of executable instruction whichis designed to and capable of executing the functionality of the presentinvention as described herein. Additionally, state diagram modeling tool220, graphical modeling tool 230, and code building tool 290, may beconfigured to and capable of running any of the modules, libraries orsoftware components of the MATLAB® and/or Simulink® product family. Assuch, the state diagram modeling environment 120 may have all or aportion of the software components of MATLAB® and/or Simulink® installedon the computing device 102, or alternatively, accessible from anothercomputing device on a network.

In FIG. 2A, although the state diagram modeling tool 220, graphicalmodeling tool 230, and code building tool 290 are illustrated asseparate tools, one ordinarily skilled in the art will recognize andappreciate that any combination or all of these tools 220, 230 and 290may be combined into a single application, or otherwise tightlyintegrated to present a single application in performing the operationsof the present invention as described.

FIG. 2B depicts another environment suitable for practicing anillustrative embodiment of the present invention, wherein portions ofthe present invention are distributed in a network environment. In abroad overview, a system 200 depicts a network 204 environment forrunning portions of the state diagram modeling environment 120 of thepresent invention on multiple computing devices 102, 102′ and 102″. Thesystem 200 includes multiple computing devices 102, 102′, and 102″connected to and communicating over a network 204. The state diagrammodeling tool 220, graphical modeling tool 230, and code building tool290 can be capable of and configured to communicate to each other overthe network 204 by any suitable means and/or mechanisms. In someembodiments, the state diagram modeling environment 120 may use theMATLAB® Distributed Computing Toolbox and Distributed Computing Engineto distribute and process any portions of the operations of the presentinvention described herein.

The network 204 can be a local area network (LAN), such as a companyIntranet, a metropolitan area network (MAN), or a wide area network(WAN) such as the Internet. In one embodiment (not shown), the network204 comprises separate networks, which may be of the same type or may beof different types. The topology of the network 204 over which thecomputing devices 102, 102′, 102″ communicate may be a bus, star, orring network topology. The network 204 and network topology may be ofany such network 204 or network topology capable of supporting theoperations of the present invention described herein.

The computing devices 102, 102′, and 102″ can connect to the network 204through a variety of connections including standard telephone lines, LANor WAN links (e.g., T1, T3, 56 kb, X.25, SNA, DECNET), broadbandconnections (ISDN, Frame Relay, ATM, Gigabit Ethernet,Ethernet-over-SONET), cluster interconnections (Myrinet), peripheralcomponent interconnections (PCI, PCI-X), and wireless connections, orsome combination of any or all of the above. Connections can beestablished using a variety of communication protocols (e.g., TCP/IP,IPX, SPX, NetBIOS, Ethernet, ARCNET, Fiber Distributed Data Interface(FDDI), RS232, IEEE 802.11, IEEE 802.11a, IEEE 802.11b, IEEE 802.11g,and direct asynchronous connections).

The network 204 and network connections may include any transmissionmedium between any of the computing devices 102, 102′, and 102″ such aselectrical wiring or cabling, fiber optics, electromagnetic radiation orvia any other form of transmission medium capable of supporting theoperations of the present invention described herein. The methods andsystems of the present invention may also be embodied in the form ofcomputer data signals, program code, or any other type of transmissionthat is transmitted over the transmission medium, or via any other formof transmission, which may be received, loaded into, and executed, orotherwise processed and used by a computing device 102, 102′ and 102″ topractice the operations of the present invention as described herein.

Each of the computing devices 102, 102′, and 102″ may be configured toand capable of running any portion of the state diagram modelingenvironment 120. The state diagram modeling environment 120 and/or anyportion thereof, such as the state diagram modeling tool 220, graphicalmodeling tool 230, and code building tool 290 can be capable of andconfigured to operate on the operating system that may be running on anyof the computing devices 102, 102′, and 102″. Each computing device 102,102′, and 102″ can be running the same or different operating systems.Additionally, state diagram modeling tool 220, graphical modeling tool230, and code building tool 290 can be capable of and configured tooperate on and take advantage of different processors of any of thecomputing devices 102, 102′, and 102″. One ordinarily skilled in the artwill recognize the various combinations of operating systems andprocessors that can be running on any of the computing devices.

FIG. 2C depicts another illustrative environment of an embodiment of thepresent invention, wherein portions of the present invention arepracticed in a client/server architecture in a network environment. In abroad overview, the illustrative state diagram modeling environment 120of the present invention includes a client computing device 102connected to and in communication with a server computing device 102′over a network 204. The state diagram modeling tool 220, graphicalmodeling tool 230 and/or code building tool 290, can be capable of andconfigured to have respective portions run on each of the client 102 andthe server 102′. In one embodiment, the state diagram modeling tool 210may have a first portion running on the client 102 and a second portion210′ running on the server 102′. For example, the state diagram modelingtool 210 may have a client portion 210 on the client 102 for providingand displaying the state diagram model 225, and a server portion 210′ onthe server 102′ that may include application functionality and otherprocessing, such as storing and/or retrieving portions of the statediagram model 225 from a database. Likewise, in other embodiments, thegraphical modeling tool 230 may also have a client portion 230 and aserver portion 230′, and the code building tool 290, a client portion290 and a server portion 290′. One ordinarily skilled in the art willrecognize and appreciate how the state diagram modeling tool 220,graphical modeling tool 230, and/or code building tool 290 may becapable of and configured to execute with a client portion and a serverportion in a client/server architecture.

Additionally, the state diagram modeling tool 220, graphical modelingtool 230, and/or code building tool 290 may be deployed such thatportions of the graphical model 235 and/or state diagram model 225 mayexecute on certain portions of the network 204 and/or on certaincomputing devices 102, 102′, or 102″. For example, some functionality ofthe graphical model 235 and/or state diagram model 225 may be timecritical or sensitive, and therefore may be targeted to execute on acomputing device 102, 102′ and 102″ and a segment or portion of thenetwork 204 with desired performance and/or operating characteristics.Other functionality of the graphical model 235 and/or state diagrammodel 225 may not be time-sensitive and may be targeted to be deployedto any computing device 102, 102′, and 102″ available on the network204.

In summary, the state diagram modeling tool 220, graphical modeling tool230, and code building tool 290 may be deployed across a wide range ofdifferent computing devices, different operating systems, and differentprocessors. Furthermore, the state diagram modeling tool 220, graphicalmodeling tool 230, and code building tool 290, may be deployed invarious distributed and/or client/server environments in various networktopologies and configurations.

In one aspect, the present invention is directed towards techniques forproviding multiple sample rates in a state machine diagram model 225.FIGS. 3A, 3B, and 3C depict illustrative state diagram models 225 forproviding multiple sample rates in accordance with the presentinvention. FIG. 3A illustrates a graphical model 235 incorporating astate diagram model 225 and having input signals with different samplingrates. FIG. 3B illustrates a state diagram model 225 using temporaloperators to provide for the calling of an output function at afrequency specified according to the temporal logic. FIG. 3C illustratesa state diagram model 225 assigning different sample rates to states ofthe model.

Referring now to FIG. 3A, a graphical model 235 is illustrated in thegraphical modeling tool 230. The graphical model 235 incorporates,references, or otherwise uses a state diagram model 225 to provide aportion of the desired functionality. The graphical model 235 mayreceive or otherwise provide one or more input signals, such as a firstinput signal 310 a, referred to as input 1 in FIG. 3A, and a secondinput signal 310 b, referred to as input 2 in FIG. 3A. Signal 310 a mayprovide a sample rate of 1 ms while the signal 310 b may provide adifferent sample rate of 10 ms. The output signals 312 a and 312 b,referred to as output 1 and output 2 respectively in FIG. 3A, mayprovide input to other functionality and/or operations associated withthe graphical model 235. The output signal 312 a may have a sample rateof 1 ms, or any multiple of 1 ms, and likewise, the output signal 312 bmay have a sample rate of 10 ms or any multiple of 10 ms.

Using the techniques of the present invention, the graphical model 235may have the input signals 310 a-301 b propagate or traverse the statediagram model 225 and generate, produce, or otherwise provide the outputsignals 312 a and 312 b. The output signals 312 a and 312 b may providea plurality of sample rates 350 as input to other elements of orassociated with the graphical model 235. A signal as used herein will bein reference to signals used in the graphical modeling tool 210 ofSimulink®, although one ordinarily skilled in the art will appreciatethat other graphical modeling environments 210 may have otherrepresentations for signal functionality as described herein. Signalsrepresent streams of information, such as data, data types, values,timing information, and control information, flowing into, out of, andbetween various elements in the graphical model 235.

Signals can be specified with a wide range of attributes includingsignal name, data type (e.g., 8-bit, 16-bit, or 32-bit integer), numerictype (complex or real), and dimensionality. A signal type refers to asignal that is a member of a class or classes of signals. Additionally,a signal can be associated with, assigned, or specified with a samplerate. For example, a sample rate of a source element can be specified orconfigured in the graphical model 235, such as a source block of a blockdiagram model. The graphical modeling tool 230 may propagate orotherwise provide for the traversal of the signal's sample rate throughother elements in the graphical model 235, and using the techniques ofthe present invention as discussed in detail below, have the signal'ssample rate propagated via the state diagram model 225.

Although the illustrative embodiments of the present invention aregenerally discussed in regards to a plurality of sample rates, thesample rates of the present invention may comprise any type and/or formof execution rate, data rate, or rate or frequency of propagation,triggering, or other activity with respect to the graphical model 235and/or state diagram model 225. As such, the sample rates of the presentinvention may represent any type and/or form of sampling, frequency, orrate of the flow of information, such as data and signals, or any typeand/or form of sampling, frequency, or rate of execution, such as thetriggering of any events or function calls.

Referring now to FIG. 3B, a state diagram model 225 using temporaloperators is illustrated. A state diagram model 225 may be provided bythe state diagram modeling tool 220 to include a state block 325representing at least a portion of the functionality of the model or thedesired state machine representation. The state block 325 may receive a1 ms input signal 310 a as input and referred to as a CLK signal in FIG.3B. The state block 325 may include temporal operators 335 a and 335 bto perform operations according to the temporal logic to provide outputsignals 312 a and 312 b. The illustrative temporal operator 335 a callsan output function “event 1”, represented by block 320 a, via outputsignal 312 a based on every second occurrence of the state 325 wakingup. The illustrative temporal operator 335 b calls an output function“event 2”, represented by block 320 b, via output signal 312 b based onevery fourth cycle of the input signal CLK 310 a.

As illustrated in FIG. 3B, the output signals 312 a-312 b provided bythe temporal operators 335 a-335 b represent multiple different samplerates 350 propagating via the state diagram model 225. Although thestate block 325 receives a single input signal 310 a at a certain samplerate, the logic of the temporal operators 335 a-335 b provide differentsampling rates 350 as output 312 a-312 b to drive, trigger, or otherwiseprovide input to the event functions 320 a-320 b.

Referring now to FIG. 3C, a state diagram model 225 providing samplerates assigned to states is illustrated. The state diagram model 225illustrates an example “debounce” logic that may be used to representand handle the transient effects of a physical switch being switched toan on or off state. As known to those ordinarily skilled in the art, atypical switch may makes multiple transitions during the time to open orclose the switch, due to effects that include age, operating inertia,mechanical design, and the condition of the switch-contact surfaces.This behavior may be referred to as “switch bounce.” In brief overview,the state diagram model 225 comprises an off state 325 a, a debouncestate 325 b and an on state 325 c along with corresponding temporaloperators 330 a, 330 b, 330 c, and 330 d. An input signal 310 provides asignal with a sampling rate as input to the state diagram model 225. Theoff state 325 a corresponds to an input signal value, i.e., a y value,of less than or equal to zero while the on state 325 c corresponds to ay value greater than zero. The debounce state 325 b is designed tocorrespond to the transient effects of a signal of a switch that occursbetween the off state 325 a and on state 325 c, in which the y value maybounce between the on and off state multiple times before reaching asteady state.

In the illustrative example of FIG. 3C, the off state 325 a and on state325 c may each be assigned a sample rate of 1 ms while the debouncestate 325 b may be assigned a different sample rate of 0.1 ms. Forexample, the debounce state 325 b may have a faster sampling rate thanthe other states as the transient of the input signal switching betweenthe off an on state may occur quickly. As such, the state diagram model225 has multiple sample rates 350 assigned to multiple states 325 a-325c.

As illustrated by the examples of FIGS. 3A-3C, a state diagram model 225may be sample rate aware and have multiple samples rates 350 associatedwith it via one or more of the following: 1) one or more input signalswith different sample rates, 2) temporal logic operators providingdifferent and/or multiple sampling rates, and 3) one or more stateshaving assigned sample rates. The multiple sample rates 350 associatedwith the state diagram model 225 may be formed via any combination ofthe above techniques. For example, a state diagram model 225 may havetwo input signals with different samples rates, a state with an assignedsample rate, and/or a temporal operator effectively providing adifferent sampling rate based from an input signal sample rate, internalclock event, or a state assigned sample rate.

Although the illustrative state diagram models 225 of FIGS. 3A-3C aregenerally described and illustrated as provided by a state diagrammodeling tool 220 such as Stateflow®, the state diagram model 225 maycomprise other types of graphical models and visual formalisms providedby any other type and/or form of visual or graphical modeling tool. Assuch, the state diagram model 225 may comprise constructs and elements,graphical or otherwise, relevant to the type and/or form of statediagram model 225 and/or state diagram modeling tool 220. One ordinarilyskilled in the art will recognize and appreciate how the techniques ofthe present invention described herein would be applied using a statediagram model 225 provided via any suitable state diagram modeling tool220.

In another aspect, the illustrative embodiment of the present inventionprovides systems and methods for processing and/or propagating multiplesample rates 350 associated with a state diagram model 225. Thetechniques of the present invention will be discussed in view ofillustrative method 400 of FIG. 4B in conjunction with the illustrativestate diagram model 225 of FIG. 4A, and the illustrative intermediaterepresentation of FIG. 4C.

In brief overview, FIG. 4A illustrates a state diagram model 225 in anexemplary embodiment of a state diagram modeling environment 220 ofStateflow®. The state diagram model 220 has two parallel Schedulerstates, “Scheduler1” and “Scheduler2”, having exclusive or, “XOR”,substates 325 a-325 d that define temporal operators to broadcast outputevents, e.g., via a send function call, at sample rates that aremultiples of samples rates provided via input clock events “CLK1”,“CLK2” and “CLK3”. Scheduler1 state includes substate A 325 a withtemporal operators 335 a and 335 b, and substate B 325 b with temporaloperator 335 c. The Scheduler2 state includes a substate A 325 c withtemporal operator 335 d, and a substate B 325 d with temporal operators335 e and 335 f. As such, the temporal operators 335 a-335 d providemultiple samples rates 350 to be considered for processing the statediagram model 225. As illustrated in the logic of states 325 a-325 d, abind statement may be used as known to those ordinarily skilled in theart to synchronize the enabling and disabling of the connectedfunction-call subsystems in a graphical model 235 with the activity ofthe bound states.

FIG. 4B depicts illustrative method 400 for processing and propagatingmultiple samples rates 350 associated with a state diagram model 225 andin conjunction with any of the illustrative environments of the presentinvention depicted in FIGS. 2A-2C. As such, the techniques of thepresent invention, or any portion thereof, may be practiced in the statediagram modeling tool 220, graphical modeling tool 230, and/or the codebuilding tool 290. The technique of the present invention uses anintermediate representation, such as a directed graph or a control flowgraph, to determine how to propagate the multiple signals 350 via thestate diagram model 225. The intermediate representation reduces thestate diagram model 225 to a sample-rate-space representation, whichprovides a structure, mechanism, and means for determining sample timepropagation.

At step 410 of illustrative method 400, a state diagram model 225 havingmultiple sample rates 350, such as the state diagram model 225illustrated in FIG. 4A, is provided in any suitable form. In oneembodiment, the state diagram model 225 may be provided via a file inany format readable by the state diagram modeling tool 220 or graphicalmodeling tool 230. In another embodiment, the state diagram model 225may be available in memory, such as in one or more data structures ormemory elements used by the state diagram modeling tool 220 or graphicalmodeling tool 230 to work with, use, or otherwise process the statediagram model 225. In a further embodiment, the state diagram model 225may be included in, incorporated with, associated or otherwise providedwith a graphical model 235. One ordinarily skilled in the art willrecognize and appreciate that the state diagram model 225 may beprovided in various forms and/or mediums in practicing the operations ofthe present invention described herein.

At step 415 of illustrative method 400, the state diagram model 225 maybe processed to determine the propagation of the one or more samplerates 350. In one embodiment, the state diagram model 225 is processedto propagate any signals traversing the elements of the model, includingthe sample rate of the signals. In another embodiment, the state diagrammodel 225 is compiled or otherwise processed to generate an executableform of the model. In one embodiment, the executable form of the statediagram model 225 may be provided in an interpreted language, and inanother embodiment, as compiled source code.

During model compilation or model processing, the state diagram modelingtool and/or graphical modeling tool 230, such as through a modelcompiler, uses a process called signal propagation to represent thetraversal of the signal and associated attributes via the connectivityof the blocks. Signal propagation may be used for creating theexecutable form of the state diagram model 225 and/or graphical model235 to simulate the behavior of the signal through the elements of thestate diagram model 225 and/or graphical model 235. As such, thepropagation of signal attributes through the connectivity represented inthe state diagram model 225 and/or graphical model 235 drive theexecution of the simulation. In reference to an exemplary embodiment ofSimulink® as the graphical modeling tool 230 and Stateflow® as the statediagram modeling tool, signal propagation is the process used todetermine attributes of signals and blocks, such as data types, labels,sample time, dimensionality, and so on, that are determined byconnectivity. The techniques of the present invention allow thepropagation of multiple sample rates via a state diagram model 225.

Although the present invention may be generally discussed as determiningthe sample rate propagation in association with a model compilationprocess, the state diagram model 225 may be processed to determinesample time propagation at any suitable time, such as a pre-compilationstep, or as an ad-hoc step. For example, a user may select to determinethe sample rate propagation of a model via a user interface of the statediagram modeling tool 220 or graphical modeling tool 230.

Still referring to illustrative step 415 of method 400 in FIG. 4B, anintermediate representation of the state diagram model 225 is generated,or otherwise provided to determine sample time propagation of multiplesample rates 350 via the state diagram model 225. FIG. 4C illustrates anintermediate representation of the state diagram model 225 of FIG. 4A.In the illustration of FIG. 4C, the intermediate representation isdepicted as a unidirectional directed graph 450, although other types ofgraphs and/or tree structures may be used. The graph 450 provides anabstract and static representation of the procedures and/or operationsof the state diagram model 225. In one embodiment, the graph 450represents all alternatives of control flow. So, for example, both pathsof an IF statement may be represented in the graph 450. In briefoverview, the illustrative graph 450 is represented by a set of objectscalled vertices or nodes, connected by links or lines called edges orarcs, which may also have associated directions. As such, a graph 450may be depicted as a set of nodes (i.e., vertices) connected by lines(i.e., edges), with an arrowhead on a line representing a directed edge.

The graph 450 may comprise various primitives or constructs to representa procedural, operation or flow of the state diagram model 225, such asfunctions and nodes. As illustrated in FIG. 4C, a function 452 a-452 dmay be used to represent the flow of each state or substate of the statediagram model 225. For example, function 452 a represents the substate A352 a of Scheduler1 as depicted in FIG. 4A. Each function 452 a-452 dhas a start node 454 a-454 d, which is a virtual node or speciallydesignated node to identify the start of the function 452 a-452 d, andcontrol entry into the flow of the graph for the function 452 a-452 d.Each function 452 a-452 d also has an end node 456 a-456 d which is avirtual node or specially designate node to indicate the end of thefunction 452 a-452 d and control exiting or leaving the flow of thegraph 450. As such, each function 452 a-452 d is identified by a pair ofstart nodes 454 a-454 d and end nodes 456 a-456 d.

Also, the graph 450 has nodes to represent conditionals and basic blocksof execution or flow. For example, conditional nodes 460 a-460 d′ ingraph 450 represent conditional logic associated with each temporaloperator 335 a-335 f in the state diagram model 225 of FIG. 4A. Nodes462 a-462 d′ in graph 450 represent a basic block or a straight-linepiece of procedural or operational flow without any jumps in controlflow or execution, such as jump to start a function or another node, orto end a function. For example, a node 462 a may be used to representthe execution of a send function based on the execution of an “on every”function. As such, nodes 460 a-460 d′ and 462 a-462 d′ representsingle-entry-single exit nodes. As illustrated in FIG. 4C, directededges or lines are used to connect the nodes in the graph 450 andrepresent jumps in the control of flow from start node tosingle-entry-single-exit nodes to the end node.

Additionally, the graph 450 may have other constructs to represent otheraspects of the control of flow, such as a merge node 464 a-464 d′ asillustrated in FIG. 4C. A merge node 464 a-464 d′ may be used to connecttwo or more edges from other nodes. For example, a conditional node 460a-460 d′ may provide a true flow edge and a false flow edge to representflow paths depending on the evaluation of the conditional. At a point inthe control of flow represented by the function 452 a-452 d, the flow ofcontrol may merge together and a merge node 464 a-464 d′ is used tomerge two edges received as input into one edge provided as output fromthe merge node 464 a-464 d′. In a similar manner, a split node (notshown) may receive a single edge as input and provide two or more edgesas output.

Although the intermediate representation is illustrated in FIG. 4C as adirected graph 450, one ordinarily skilled in the art will recognize andappreciate that any type and/or form of suitable graph or intermediaterepresentation may be used in practicing the techniques of the presentinvention described herein. For example, in some embodiments, a controlflow graph, a tree structure graph, or matrix may be used. As such, theintermediate representation 450 may comprise constructs and elements,graphical or otherwise, relevant to the type and/or form of intermediaterepresentation 450. One ordinarily skilled in the art will recognize andappreciate how the techniques of the present invention described hereinwould be applied using an intermediate representation 450 provided in aform other than as illustrated in FIG. 4C.

By way of example, the functions 452 a-452 d illustrated in FIG. 4C willbe discussed in relation to the representation of the control of flowfor the respective states 325 a-325 d illustrated in FIG. 4A. Function452 a represents the control of flow for substate A 325 a of Scheduler1of the state diagram model 225. Function 452 a provides a start node 545a which flows into node 462 a″ representing the “bind: E1, E2”instruction. Node 462 a″ flows into conditional node 460 a representingthe “on every (1, CLK1)” instruction 335 a, which flows into a true andfalse edge. If the instruction 335 a is evaluated to be true orotherwise is to be executed, the node 460 a flows via the true edge intonode 462 a to represent the “send (E1)” instruction. The false edge fromthe node 462 a″ and the edge from 462 a merge at merge node 464 a, whichflows into a second conditional node 460 a′ representing the second “onevery” instruction 335 b of the state 325 a. If the conditional of node460 a′ is true, the true edge flows into node 462 a′ which representsthe “send (E2)” instruction. Otherwise, the false edge from node 460 a′flows into merge node 464 a′ with the flow from node 462 a′. The mergenode 464 a′ then flows into end node 456 a.

Function 452 b represents the control flow of state block 325 b. Thestart node 54 b flows into the node 462 b′ representing the bindinstruction of the state 325 b. Node 462 b′ flows into the conditionalnode 460 b representing the temporal operator “on every” instruction 335c. The true edge of the conditional node 460 b flows into node 462 b torepresent the “send (E8)” instruction, and the flow from node 462 bmerges with the false edge of the conditional node 460 b at merge node464 b. The merge node 464 b then flows into end node 456 b to completethe control of flow for function 452 b.

In a similar manner as function 452 b, function 452 c represents thecontrol of flow of stare block 325 c of state diagram model 225illustrated in FIG. 4A. Node 462 c′ represents the bind instructionwhile node 460 c represents the temporal operator instruction 335 d. Ifthe temporal operator is triggered, the true edge flows into node 462 crepresenting the corresponding send instruction. The false edge of node460 c and the flow from node 462 c merge at the merge node 456 c, whichin turns flows into end node 456 c to complete the function 452.

Likewise, in a similar manner as function 452 a, function 452 drepresents state block 325 d of state diagram model 225 illustrated inFIG. 4A. State block 325 d has a bind instruction followed by twotemporal operators 335 e and 335 f. The corresponding function 452 d ofgraph 450 represents the bind instruction with node 462 d″ which flowsinto node 460 d representing the first temporal operator 335 e. On thetrue edge, node 462 d represents the send instruction corresponding tothe first temporal operator 335 c, which flows into the first merge node464 d to merge with the false edge of node 460 d. The merge node 460 dflows into node 460 d′ representing the second temporal operator 335 f.Node 460 d′ flows into node 462 d′ and the merge node 464 d′ for thetrue and false edges respectively. The output flow of node 462 d alsoflows into the merge node 464 d′ to merge with the false path of node460 d′. The merge node 464 d′ flows into the end node 456 d to representthe end of the flow of control for the function 452 d.

In view of the example illustrations of functions 452 a-452 d of thegraph 450, one ordinarily skilled in the art will recognize andappreciate applying the intermediate representation of a state diagrammodel 225 to other state diagram models 225 having less or more states325 a-325 d with various and different instructions, including differenttypes of temporal operators. For example, the intermediaterepresentation 450 may be generated to provide a unidirectional directedgraph representation of any type and/or form of state diagram model 225provided via the exemplary embodiment of Stateflow® as the state diagrammodeling tool 220.

In continuing at step 415 of illustrative method 400, the graph 450 ofFIG. 4C provides a static representation of the control of flow of thestate diagram model 225 that can used to analyze and determine thepropagation of samples rate via the elements of the state diagram model225. At illustrative step 420, the propagation of sample rates can besimulated, analyzed, and determined via the graph 450. In oneembodiment, a time variable 470 a-470 d may be assigned to each function452 a-452 d to assess changes in the sample rate by any node as the timevariable propagates the flow of the graph 450. The time variable 470a-470 d may represent the sample rate of any input signal, a state, aninput event, or a temporal operation. In some embodiments, the timevariable 470 a-470 d may represent the sample rate of an internal clockof the state diagram model 225 or the function call input events from agraphical model 225, such as “CLK1”, “CLK2”, and “CLK3” eventsillustrated in FIG. 4A in an exemplary embodiment of Stateflow® as thestate diagram modeling tool 220 and Simulink® as the graphical modelingtool 230. In other embodiments, the time variable represents a signal ofSimulink® propagating via the elements of the state diagram model 225.

In another embodiment, the time variable 470 a-470 d may represent aninitial value, such as a normalized value of 1, 100, or 1000, thatindicates a multiplier for a sample rate. For example, the time variable470 a-470 d may initially be set to a value of 1, and furtherrepresenting any unit of time. As the time variable 470 a-470 dpropagates via the static representation of the graph 450, the timevariable may be increased or decreased according to the functionality,logic, procedure or operations represented by each node. The resultingtime variable 470 a-470 d may indicate a multiplier of the actual samplerate of a corresponding input, such as an input signal or input event.

In some embodiments, each output function, signal, or event of the statediagram model 225 may be assigned a sample rate based on the value ofthe time variable 470 a-470 d at the point in the graph 450 triggeringor causing the output activity. In some embodiments, the slowest orlowest common sample rate may be used for any portion of the graph 450,such as any output function. For example, if an output function E1 iscalled multiple times within a function 452 a-452 d, the lowest samplerate to be propagated through a node calling function E1 may be selectedas the sample rate to use in the executable form of the state diagrammodel 225.

By way of example, the propagation of a sample rate represented by atime variable 470 a-4670 d will be discussed in connection with theillustrative graph 450 of FIG. 4C. At each edge or connecting line ofthe graph, a value for the time variable 470 a may be determined torepresent the propagation of a sample rate. A time variable 470 ainitially set to 1 may be assigned at the start 454 a of function 452 a.As the time variable 470 a propagates the node 462 a″, the bindoperations of node 462 a″ does not change or alter the time variable 470a as it does not perform any temporal or time related operations. Assuch, the value of the time variable 470 at the point of flow outputfrom node 462 a″ remains set to 1. After traversing node 460 arepresenting the conditional of the temporal operator 335 a, the timevariable 470 a may have a value for the false edge and the true edge.Since the false edge does not change the sample rate, the time variable470 a remains set to 1. On the true edge, the time variable is set to avalue representing the change to sample rate from the temporal operator335 a. Since the temporal operator indicates a trigger on everyoccurrence of the input event “CLK1”, the time variable 470 a is set toor otherwise remains at 1. As such, the node 462 a representing the sendE1 instruction is associated with a time variable 470 a set to 1.

The input flows to the merge node 464 a both have a time variable 470 avalue of 1. Therefore, the time variable 470 a of 1 is passed to node460 a′ to determine changes in sample rate via the control of flow ofthe second temporal operator 335 b of state 325 a. In some embodiments,the fastest sample rate representation is passed via the merge node 464a. In other embodiments, the lowest common sample rate or slowest samplerate may be passed as output by the merge node 464 a. For the false edgeoutput of node 460 a′, the time variable 470 a remains unchanged and setto a value of 1. For the true edge output of node 460 a′, the timevariable 470 b is set to 2 to represent that the temporal operator 335 bis executed on every second occurrence of the input event CLK2. Themerge node 464 a′ is provided a time variable 470 a of 1 and timevariable 470 a of 2 from the false and true edges, respectively. Thetime variable 470 a may be set to the fastest rate of 1 to the next edgewhich terminate the flow of control via the end node 456 a.

In view of the analysis of the values of the time variable 470 apropagated via the static representation of the graph 450, the outputfunction E1 may be called at a sample rate of 1 times the CLK1 inputevent or for every occurrence of the CLK1 input event, and the outputfunction E2 at a sample rate of every second occurrence of the CLK2input event or half the sample rate of the CLK2 input event. With thedetermination of the propagation of the sample rates 350 through thestate diagram model 225, an executable form of the state diagram model225 may be generated or otherwise provided to execute using thedetermined samples rate 225.

In another example of step 420 of illustrative method 400, thepropagation of the time variable 470 b is determined for function 452 brepresenting the state 325 b of the state diagram model 225 of FIG. 4A.An initial value of 1 is set for time variable 470 a for propagatingfrom the start block 454 b. For the example, the time variable 470 b mayrepresent a sample rate of 1 ms of the input event CLK3, or inputsignal, or assigned to the state block 325 b. Node 462 b′ does not alterthe time variable 470 b setting, and on the false edge of conditionalnode 460 b the time variable 470 b flows unchanged to the merge node 464b. On the true edge output of node 460 b, the time variable 470 b is setto a value of 8 to represent that on the 8^(th) occurrence of the inputevent CLK3, the “send E8” instruction will be executed. As such, thesend E8 output function has a sample rate of ⅛ th of the sample rate ofCLK3.

In a similar example, the propagation of the time variable 470 c via thefunction 452 c provides a time variable 470 c value of 4 assigned to theexecution of the instruction “send E4” represented by node 462 c. Thetime variable 470 c is set to a value of 1 for the flows through theother connecting lines of function 452 c. Via the analysis of the valuesof the time variable 470 c, the sample rate for the output function callof “send E1” is ¼^(th) the sample rate of the corresponding CLK1 event.

In a further example illustrated in FIG. 4C, the time variable 470 d ispropagated via the flows and nodes of the function 452 d of graph 450.In accordance with the temporal operations of nodes 462 d and 462 d′,the time variable 470 d is set to a value of 16 for the “send E16”instruction of node 462 d and a value of 2 for the “send E1” instructionof node 462 d′. As such, the “send E16” output function is assigned asample rate of 1/16^(th) of the sample rate of CLK3 or otherwise onevery 16^(th) occurrence of CLK3. In the case of the “send E1”instruction, this is the second occurrence of this output function asthe “send E1” output function is also represented by node 462 a offunction 452 a. In some embodiments, in order to assign a common samplerate to each of these calls to the same function, the lowest common orslowest sample rate is used. By this example, the time variable 470 a isset to 1 for the first instance of the output function represented bynode 462 a in function 452 a and time variable 470 d is set to 2 for thesecond instance of the output function represented by node 463. Thesecond instance has the lower sample rate of ½ the sample rate of inputevent CLK1 and is assigned as the sample rate for all output functioncalls to E1 in graph 450. In other embodiments, each instance of theoutput call to function E1 may be assigned the propagated sample ratecorresponding to their use in the respective functions 452 a and 452 d.

In some embodiments, the propagation of a time variable 470 a-470 dthrough a function 452 a-452 d represents the propagation of one inputsignal of a plurality of input signals, such as input signal 310 a ofstate diagram model 225 illustrated in FIG. 3A. A second propagation ofa time variable 470 a-470 d may be performed to determine the samplerate corresponding to a second input signal, such as input signal 310 billustrated in FIG. 3A. For example, the state block 325 a representedby function 454 a may be associated with input signals 310 a and 310 b.From the sample rate propagation analysis of illustrative step 420 foreach input signal 310 a-310 b, the lowest sample rate assigned to node460 a calling output function E1 may be used for the executable form ofthe state diagram model 225.

At step 425 of illustrative method 400, an executable form of the statediagram model 225 is generated or otherwise provided using the samplerates determined via the static representation of the graph 450 at step420. In this manner, the executable form represents the sample-rateaware state diagram model 225. In one aspect, the executable form isgenerated from the graph 450 representation of the state diagram model225, such as the illustrative graph 450 of FIG. 4C representing theillustrative state diagram model 225 of FIG. 4A. By reducing thereactive, event-based, and sample-time aware state diagram model 225 toa static representation, such as a directed graph 450, code can begenerated to represent the static representation and the determinedsample times, such as the sample times determined via the techniquesillustrated at step 420. Additionally, for output signals, functions, orevents being triggered or driven by the state diagram model 225 andassociated with multiple and/or different sample rates 350, thetechniques of the present invention reduce the state diagram model 225to a static representation using a suitable sample rate, e.g. leastcommon or lowest sample rate, for the output signal, function, or event.The techniques of the present invention provide efficient coderepresentation of a sample rate aware state diagram model 225.

In one embodiment, source code is generated to reflect the staticrepresentation of the state diagram model 225 with the determined samplerates. The source code may be compiled and linked to generate anexecutable. An illustrative embodiment of the present invention togenerate code for the state diagram model 225 comprising the multiplesample rates will be discussed in further detail below in conjunctionwith FIGS. 5A and 5B. In another embodiment, an interpretive language,such as MATLAB®, may be used to represent the state diagram model 225with the determined sample rates in executable form. For example, theinterpretive language may be used to simulate the state diagram model225 in the state diagram modeling tool 220. One ordinarily skilled inthe art will recognize and appreciate that the executable from of thestate diagram model 225 may take many forms using a variety oflanguages, such as programming and interpretive languages.

At step 430 of illustrative method 400, the present invention is relatedto executing an executable form of the state machine diagram model 225,either in an interpretative mode or in the accelerated mode. Ininterpretative mode, either the state diagram modeling tool 220 and/orgraphical modeling tool 230 can execute a state diagram model 225 and/orgraphical model 235 incorporating the state diagram model 225 in theirrespective environments in a graphical fashion. In other embodiments,code can be generated from the state diagram model 225 and/or graphicalmodel 235 to build an executable program for the accelerated mode ofexecuting the model 225. The execution of the executable form of thestate diagram model 225 uses the sample rates determined via the staticintermediate representation 450 as illustrated in the techniques of step420.

Referring now to FIGS. 5A and 5B, an illustrative method 500 of FIG. 5Aand system 502 of FIG. 5B of the present invention will used to discussthe operations, functions, and structure of the code generationtechniques of the present invention. Referring to FIG. 5B, in briefoverview, the code generating system 502 comprises a code building tool290 having a code generator 295. In an exemplary embodiment of a statediagram modeling environment 120 of Stateflow® and Simulink®, the codebuilding tool 290 comprises the Stateflow® Coder integrated withReal-Time Workshop®, both manufactured by The Mathworks, Inc.

Referring to FIG. 5A, the illustrative method 500 of the presentinvention obtains either a state machine diagram model 225 at step 505,or in another embodiment, a graphical model 235 referencing the statemachine diagram model 225 at step 505′. In some embodiments, the statemachine diagram model 225 and/or the graphical model 235 may be obtainedvia a file. The state machine diagram model 225 and/or the graphicalmodel 235 may comprise a file in a format that the code building tool290 or code generator 295 can read and that follows a file specificationfor defining state machines and other elements of the state machinediagram model 225. In other embodiments, the code building tool 290and/or code generator 295 may obtain either the state machine diagrammodel 224 and/or the graphical model 235 from an application programminginterface (API) call to another application or via an interface toanother environment, such as the state diagram modeling tool 210. In yeta further embodiment, the graphical mode simulation tool 230 and/or thestate diagram modeling tool 210, or another computer program, saves andconverts the state machine diagram model 225 and/or graphical model 235into a format readable by the code building tool 290. For example, agraphical model 235 produced with Simulink® and Stateflow® may beconverted into an intermediate model file representation such as an .rtwtype file readable by the automatic code generator of Real-TimeWorkshop®.

At step 510 of illustrative method 500, the code building tool 190, suchas Stateflow® Coder and/or Real-Time Workshop®, will generate code forthe graphical model 235 and/or state machine diagram model 225. The codebuilding tool 290 and code generator 295 use one or more input files 522in conjunction with reading and processing the graphical model 235and/or state machine diagram model 225.

The one or more input files 522 may comprise files including templates,commands, input parameters, configuration data, source code, data andclass definitions, component configuration, device driver or any otherinformation that may be used by the code generator 295 to generate codefor the graphical model 235 and/or state machine diagram model 225. Theinput files 522 may include files to provide input to and configure thecode generator 295 to generate source code files 530 for a specifictarget hardware platform, for example, a specific processor. In anexemplary embodiment of Real-Time Workshop® as the code generator 295,Real-Time Workshop® uses target language compiler script files, with a.tlc file extension, as input files 522 to the code generation process.The .tlc files provide sections of programming instructions to beimplemented for block and element references as they may be found in thegraphical model 235 and state machine diagram model 235 during the codegeneration process. The .tlc files also can provide data and classdefinitions for data element references found in the graphical model 235and/or state machine diagram model 225. Additionally, the .tlc filesalso comprise compiler directives, built-in functions and other codegeneration commands to direct Real-Time Workshop® during the codegeneration process.

In operation, the code generator 295 reads in information regarding or arepresentation of the graphical model 235 and/or state machine diagrammodel 225 and uses the input files 522 to generate code by translatingthe graphical model 235 and/or the state machine diagram model 225 intoone or more source code files 530. By way of example, the automatic codegeneration can be discussed in terms of generating code with Real-TimeWorkshop® from a block model diagram 215 generated with Simulink®.Simulink® creates and stores block diagram models 235 into model fileswith an .mdl file extension. As part of the code generation process,Real-Time Workshop® reads in an .mdl model file and analyzes the modelto generate an intermediate model file with an .rtw extension. Thisintermediate .rtw model file comprises a hierarchical structure ofrecords describing systems and their blocks and connections analyzedfrom a block diagram model 235 of the .mdl file.

In one embodiment, the code building tool 290 and/or code generator 295performs the techniques depicted in steps 415, 420 and 425 ofillustrative method 400 to generate code for the state diagram model225. As such, the code building tool 290 and/or code generator 295 mayreduce the state diagram model 225 into a static representation andperform sample time propagation analysis via the static representationto provide the code for the executable form. In one embodiment, the codebuilding tool 290 performs the techniques of the present invention whengenerating the intermediate model .rtw file In another embodiment, thecode building tool 290 may perform the techniques of the presentinvention when processing the generated .rtw file to provide code.

A language compiler called the target language compiler of Real-TimeWorkshop® works with .tlc files and .rtw files to produce code. Thetarget language compiler interprets a program that reads theintermediate model file description of an .rtw file. As the targetlanguage compiler encounter a record in the .rtw file, it usesdirectives in the .tlc files corresponding to the record to direct thecode generation process for the specific record. As such, the targetlanguage compiler works much like a text processor. For example, thetarget language compiler uses block .tlc files, which specify theparticular code for a block, to transform each block into code. When itreads a record in the .rtw file that references a block, the targetlanguage compiler applies code from the corresponding block .tlc file togenerate code for the block in source code files 522. Additionally,model wide .tlc files are also used to provide input to the targetlanguage compiler for global customization of the code. Model wide .tlcfiles may direct the target language compiler to generate main routinesto provide entry points into the program, source code header files tosetup data structures, and utility functions to support code forparticular blocks. The block and model wide .tlc files can be modifiedto generate customized code for blocks and to generate any desiredglobal customizations to the code.

The source code files 530 generated from the code generator 295, such asReal-Time Workshop®, may comprise program instructions of a programminglanguage, such as C, which may further be in a format and stylefollowing the ANSI/ISO C standard. Additionally, the source code files530 may be generated to comprise fixed-point or floating-point sourcecode. The programming instructions of the source code files 530 may begenerated to run on any real-time operating system or for a specificprocessor. In a further embodiment, the programming instructions of thesource code files 530 may be optimized for performance or versatility,and/or for a specific target hardware platform. In another embodiment,the code generator 295 can be configured via the input files 522 togenerate custom source code comprising a style and format as directed bythe input files 522. The code generator 295 can be also configured viathe input files 522 to provide customized source code to support suchcustomizations as error handling, optimization, code and data reduction,code reusability, scoping of variables, and other characteristics of thesource code that may be modified during the source code generationprocess.

In some embodiments, a portion of the source code 530 or object code 531generated or provided by illustrative method 500 may be targeted to runon a specific computational hardware device, such as an embeddedhardware platform, or a specific processor of a computing device 102 andanother portion may be targeted to run on a personal computer, such as adesktop or notebook. For example, a portion of the state diagram model224 may process data or perform loops that are time critical. Incomparison, the display may not need to be updated in a time criticalmanner as the viewer's eyes may only perceive updates at a certain rate.The time critical data processing or loops may be embodied in sourcecode 530 and/or object code 531 targeted for a specific processor of acertain speed or capability and the non-time critical code 530, 531 maybe targeted for any general computing device. One ordinarily skilled inthe art will recognize and appreciate the various ways to process andtarget various portions of code to meet the desired functionality and/orexecution of the state diagram model 225.

At step 515 of illustrative method 500, one or more programs may bebuilt from the automatically generated code to provide an executableform to execute the state diagram model 225. The code building tool 290also provides for the building of the source code files 530 into objectcode 531 to generate one or more programs to run on a target platformand/or operating system. The build process of illustrative step 515 ofthe present invention may include compiling the code and linkinglibraries, drivers, and other programs via a make program or some othercompiling utility. In one embodiment, the code building tool 290 invokesa compiler provided by software available with the operating system,such as a make utility on a UNIX operating system. In anotherembodiment, the compiler may be provided from a software developmentpackage such as Visual C/C++ from Microsoft Corporation of Redmond,Wash. One ordinarily skilled in the art will recognize the code buildingtool 290 may invoke any type of compiler that is configured to andcapable of translating the source code 530 into object code 531 to beexecuted by the target computing device 102.

Although the code generator 295 is generally discussed in terms ofgenerating source code, the code generator 295 may provide code in anyother form, such as object code, pre-existing source code, or otherprogrammable instructions suitable for representing the functionality ofthe graphical model 235 and state machine diagram model 225.Additionally, although the illustrative embodiment of the presentinvention is discussed in terms of source code files 530 and object code531 from a programming language like C, the code generator 295 maygenerate any type of programming related output, such as an interpretedprogramming language and/or scripting language. For example, the codegenerator 295 may generate code for perl, awk, VBscript, Javascript,tcl, or the technical computing programming language of MATLAB®. Inother cases, the code generator 295 may generate output in other typesof languages, such as the hardware description language of HDL. Oneordinarily skilled in the art will recognize the various types oflanguages the code building tool may apply in generating code and howthe code generator may build the code based on the type of language.

In view of the structure, functions and operations of the systems andmethods as described herein, the present invention provides techniquesfor designing and constructing sample-time aware state diagram models,and processing the state diagram models to provide executable formsincorporating the one or more samples times propagating via the model.The techniques of the present invention reduce state diagram models to astatic intermediate representation for sample-time propagation analysisfrom which code can be generated to provide an executable form. Thisenables state diagram models to integrate and work with dynamic systemmodels that represent and propagate multiple sample times of differentcomponents in a system. Using the present invention, a sample time awarestate diagram model can be used to schedule the execution of thedifferent components of a dynamic system model based on sample ratepropagation. In additional examples, the techniques of the presentinvention can be used to implement a sample time aware state diagrammodel for fault-management systems where the system needs to be woken upat different rates based on whether an error state has been reached ornot, or for operating system modeling where task switching isimplemented by polling and co-routining.

Many alterations and modifications may be made by those having ordinaryskill in the art without departing from the spirit and scope of theinvention. Therefore, it must be expressly understood that theillustrated embodiments have been shown only for the purposes of exampleand should not be taken as limiting the invention, which is defined bythe following claims. These claims are to be read as including what theyset forth literally and also those equivalent elements which areinsubstantially different, even though not identical in other respectsto what is shown and described in the above illustrations.

What is claimed is:
 1. A method for processing a state diagram model topropagate a plurality of rates associated with one or more elements ofthe state diagram model, the method comprising: providing, using acomputing device, an executable state diagram model having one or moreelements, the executable state diagram model having a plurality of ratesassociated with the one or more elements, the plurality of rates havinga first rate and a second rate, the plurality of rates comprising one ormore of sample rates, execution rates, or data rates; and processing,using the computing device, the executable state diagram model to:generate, from the executable state diagram model, a staticrepresentation of a control flow of the state diagram model, where: thestatic representation is a rate-space representation that includes aplurality of time variables, the plurality of time variables representthe plurality of rates, determine how to propagate the plurality ofrates via the executable state diagram model based on propagation of theplurality of time variables through the static representation, propagatethe plurality of rates via the one or more elements of the executablestate diagram model, and provide an executable form of the executablestate diagram model, the executable state diagram model including theplurality of rates propagated via the one or more elements of theexecutable state diagram model.
 2. The method of claim 1, comprisingproviding at least one of the plurality of rates via a portion of asignal provided as an input to the one or more elements of the statediagram model.
 3. The method of claim 1, comprising providing anexecutable instruction associated with the state diagram model toprovide at least one of the plurality of rates by changing a frequencyof one of a propagation of a signal or a calling of an output function.4. The method of claim 1, comprising assigning one of the plurality ofrates to one or more states of the state diagram model.
 5. The method ofclaim 1, wherein the static representation comprises one of a directedgraph or a control flow graph.
 6. The method of claim 1, comprisingprocessing the static representation to determine from the plurality ofrates a rate to apply for one of an output signal or output function ofthe state diagram model.
 7. The method of claim 1, wherein the firstrate is different than the second rate.
 8. The method of claim 1,comprising providing the state diagram model via a graphical model thatincorporates or references the state diagram model.
 9. The method ofclaim 1, comprising associating a first portion of the state diagrammodel using the first rate or a second portion of the state diagrammodel using the second rate with an output to a graphical model.
 10. Themethod of claim 1, comprising processing the state diagram model toprovide the executable form by generating code representing the statediagram model and compiling the code into an executable file.
 11. Amethod for executing a state diagram model to propagate multiple rates,the method comprising: processing, using a computing device, anexecutable state diagram model to: generate, from the executable statediagram model, a static representation of a control flow of theexecutable state diagram model, where: the static representation is arate-space representation that includes a plurality of time variables,the plurality of time variables represent multiple rates, determine howto propagate the multiple rates via the executable state diagram modelbased on propagation of the plurality of time variables through thestatic representation, propagate the multiple rates via one or moreelements of the executable state diagram model, the multiple ratescomprising one or more of sample rates, execution rates, or data rates,and provide an executable form of the executable state diagram model,the executable state diagram model including the multiple ratespropagated via the one or more elements of the executable state diagrammodel; and executing, using the computing device, the executable form touse a first rate of the multiple rates for a first portion of theexecutable form and a second rate of the multiple rates for a secondportion of the executable form.
 12. The method of claim 11, wherein theprocessing comprises propagating a first input signal having the firstrate and propagating a second input signal having the second rate. 13.The method of claim 11, wherein processing comprises providing one ofthe first rate or the second rate to one of an output signal or anoutput function of the state diagram model.
 14. The method of claim 11,wherein the one or more elements represent one of a first state assignedthe first rate or a second state assigned the second rate.
 15. Themethod of claim 11, wherein the executing the executable form provides asimulation of the state diagram model.
 16. The method of claim 11,wherein the first rate is different than the second rate.
 17. The methodof claim 11, wherein an executable form of a graphical model comprisesthe executable form of the state diagram model.
 18. The method of claim11, comprising providing an output to a graphical model by executing oneof the first portion of the state diagram model using the first rate orthe second portion of the state diagram model using the second rate. 19.The method of claim 11, comprising providing the executable form of thestate diagram mode by generating code representing the state diagrammodel and compiling the code into an executable file.
 20. A system forprocessing a state diagram model to propagate a plurality of ratesassociated with one or more elements of the state diagram model, thesystem comprising: a storage to store an executable state diagram modelhaving a plurality of rates associated with one or more elements of theexecutable state diagram model, the plurality of rates having a firstrate and a second rate, the plurality of rates comprising one or more ofsample rates, execution rates, or data rates; and a processor to processthe executable state diagram model to: generate, from the executablestate diagram model, a static representation of a control flow of thestate diagram model, where: the static representation is a rate-spacerepresentation that includes a plurality of time variables, theplurality of time variables represent the plurality of rates, determinehow to propagate the plurality of rates via the executable state diagrammodel based on propagation of the plurality of time variables throughthe static representation, propagate the plurality of rates via the oneor more elements of the executable state diagram model, and provide anexecutable form of the executable state diagram model, the executablestate diagram model including the plurality of rates propagated via theone or more elements of the executable state diagram model.
 21. Thesystem of claim 20, wherein the state diagram model comprises a signalhaving a rate provided as an input to the one or more elements.
 22. Thesystem of claim 20, wherein the state diagram model comprises anexecutable instruction providing one of the plurality of rates bychanging a frequency of a propagation of a signal via the one or moreelements.
 23. The system of claim 20, wherein the state diagram modelcomprises one or more states assigned one or more of the plurality ofrates.
 24. The system of claim 20, wherein the static representationcomprises one of a directed graph or a control flow graph.
 25. Thesystem of claim 20, wherein the processing tool uses the staticrepresentation to determine from the plurality of rates a rate to applyfor one of an output signal or an output function of the state diagrammodel.
 26. The system of claim 20, wherein the processing tool providesan executable form to use the first rate for a first portion of theexecutable form and the second rate for a second portion of theexecutable form.
 27. The system of claim 20, wherein the processing toolpropagates a first input signal having the first rate and propagates asecond input signal having the second rate.
 28. The system of claim 20,wherein the processing tool applies one of the first rate or the secondrate to one of an output signal or an output function of the statediagram model.
 29. The system of claim 20, wherein the one or moreelements represent one of a first state assigned the first rate or asecond state assigned the second rate.
 30. The system of claim 20,wherein the executable form is executed to provide a simulation of thestate diagram model.
 31. The system of claim 20, wherein the first rateis different than the second rate.
 32. The system of claim 20, whereinthe state diagram model is provided via a first computing device and theprocessing tool executes on a second computing device.
 33. The system ofclaim 20, wherein one of a first portion or a second portion of theexecutable form executes on one of a first computing device or a secondcomputing device.
 34. The system of claim 20, wherein an executable formof a graphical model comprises the executable form of the state diagrammodel.
 35. The system of claim 20, wherein an output is provided to agraphical model by executing a first portion of the state diagram modelusing the first rate or a second portion of the state diagram modelusing the second rate.
 36. The system of claim 20, wherein theprocessing tool comprises a code generator for generating coderepresenting the state diagram model and compiling the code into anexecutable file.
 37. One or more non-transitory computer readable mediastoring executable instructions that, when executed on a processinglogic unit, cause the processing logic unit to process a state diagrammodel to propagate a plurality of rates associated with one or moreelements of the state diagram model, the non-transitory computerreadable media storing one or more instructions for: providing anexecutable state diagram model having one or more elements, theexecutable state diagram model having a plurality of rates associatedwith the one or more elements, the plurality of rates having a firstsample rate and a second sample rate, the plurality of rates comprisingone or more of sample rates, execution rates, or data rates; andprocessing the executable state diagram model to: generate, from theexecutable state diagram model, a static representation of a controlflow of the executable state diagram model, where: the staticrepresentation is a rate-space representation that includes a pluralityof time variables, the plurality of time variables represent theplurality of rates, determine how to propagate the plurality of ratesvia the executable state diagram model based on propagation of theplurality of time variables through the static representation, propagatethe plurality of rates via the one or more elements of the executablestate diagram, and provide an executable form of the executable statediagram model, the executable state diagram model including theplurality of rates propagated via the one or more elements of theexecutable state diagram.
 38. The non-transitory computer readable mediaof claim 37, comprising instructions for providing at least one of theplurality of rates via a portion of a signal provided as an input to theone or more elements of the state diagram model.
 39. The non-transitorycomputer readable media of claim 37, comprising instructions forproviding an executable instruction associated with the state diagrammodel to provide at least one of the plurality of rates by changing afrequency of one of a propagation of a signal or a calling of an outputfunction.
 40. The non-transitory computer readable media of claim 37,comprising instructions for assigning one of the plurality of rates toone or more states of the state diagram model.
 41. The non-transitorycomputer readable media of claim 37, wherein the static representationcomprises one of a directed graph or a control flow graph.
 42. Thenon-transitory computer readable media of claim 37, comprisinginstructions for processing the static representation to determine fromthe plurality of rates a rate to apply for one of an output signal oroutput function of the state diagram model.
 43. The non-transitorycomputer readable media of claim 37, wherein the first rate is differentthan the second rate.
 44. The non-transitory computer readable media ofclaim 37, comprising instructions for providing the state diagram modelvia a graphical model that one of incorporates or references the statediagram model.
 45. The non-transitory computer readable media of claim37, comprising instructions for associating a first portion of the statediagram model using the first rate or a second portion of the statediagram model using the second rate with an output to a graphical model.46. The non-transitory computer readable media of claim 37, comprisinginstructions for processing the state diagram model to provide theexecutable form by generating code representing the state diagram modeland compiling the code into an executable file.
 47. One or morenon-transitory computer readable media storing executable instructionsthat, when executed on a processing logic unit, cause the processinglogic unit to execute a state diagram model to propagate multiple rates,the non-transitory computer readable media storing one or moreinstructions for: processing an executable state diagram model to:generate, from the executable state diagram model, a staticrepresentation of a control flow of the executable state diagram model,where: the static representation is a rate-space representation thatincludes a plurality of time variables, the plurality of time variablesrepresent multiple rates, determine how to propagate the multiple ratesvia the executable state diagram model based on propagation of theplurality of time variables through the static representation, propagatethe multiple rates via one or more elements of the executable statediagram model, the multiple rates comprising one or more of samplerates, execution rates, or data rates, and provide an executable form ofthe executable state diagram model, the executable state diagram modelincluding the multiple rates via one or more elements of the executablestate diagram model; and executing the executable form to use a firstrate of the multiple rates for a first portion of the executable formand a second rate of the multiple rates for a second portion of theexecutable form.
 48. The non-transitory computer readable media of claim47, wherein the processing comprises propagating a first input signalhaving the first rate and propagating a second input signal having thesecond rate.
 49. The non-transitory computer readable media of claim 47,wherein the processing comprises providing one of the first rate or thesecond rate to one of an output signal or an output function of thestate diagram model.
 50. The non-transitory computer readable media ofclaim 47, wherein the one or more elements represent one of a firststate assigned the first rate or a second state assigned the secondrate.
 51. The non-transitory computer readable media of claim 47,wherein the executing the executable form provides a simulation of thestate diagram model.
 52. The non-transitory computer readable media ofclaim 47, wherein the first rate is different than the second rate. 53.The non-transitory computer readable media of claim 47, wherein anexecutable form of a graphical model comprises the executable form ofthe state diagram model.
 54. The non-transitory computer readable mediaof claim 47, comprising instructions for providing an output to agraphical model by executing one of the first portion of the statediagram model using the first rate or the second portion of the statediagram model using the second rate.
 55. The non-transitory computerreadable media of claim 47, comprising instructions for providing theexecutable form of the state diagram mode by generating coderepresenting the state diagram model and compiling the code into anexecutable file.
 56. A system comprising: a processor to: process anexecutable state diagram model to: generate, from the executable statediagram model, a static representation of a control flow of theexecutable state diagram model, where: the static representation is arate-space representation that includes a plurality of time variables,the plurality of time variables represent multiple rates, determine howto propagate the multiple rates via the executable state diagram modelbased on propagation of the plurality of time variables through thestatic representation, propagate the multiple rates via one or moreelements of the executable state diagram model, the multiple ratescomprising one or more of sample rates, execution rates, or data rates,and provide an executable form of the executable state diagram model,the executable state diagram model including the multiple ratespropagated via one or more elements of the executable state diagrammodel and execute the executable form to use a first rate of themultiple rates for a first portion of the executable form and a secondrate of the multiple rates for a second portion of the executable form,and to provide a simulation of the executable state diagram model; and astorage for storing a result of the simulation of the executable statediagram model.